import Vue from "vue"; //引入vue核心库
import App from "./App.vue"; //引入一个当前目录下的App.vue的组件
import store from "./store/"; //引入store
import router from "./router/"; //导入路由
import installPlugins from "./plugins";
import Config from "./config/app";
import "./assets/css/style.scss";
import { isLogin } from "./utils/dataStorage";
import "flex.css";

Vue.use(installPlugins);

let whiteRouterOrde = ["/login", "/registry", "/forgetPw"];
router.beforeEach((to, from, next) => {
    window.document.title = to.meta.title ? to.meta.title : Config.siteName;
    if (!isLogin() && !whiteRouterOrde.includes(to.path)) {
        next({ path: "/login" });
    } else {
        next();
    }
});

new Vue({
    //生成一个vue实例
    el: "#app",
    router, //等同于router:router(上面已经导入)
    store, //传递给vue实例
    render: h => h(App) //渲染函数，将组件App渲染到挂载的元素上
});
